import request from '../request'
import type { ApiResponse, PaginationParams, PaginationResponse } from '../types'

export interface Version {
  id: number
  tenantId: number
  name: string
  version: string
  type: number
  url: string
  forceUpdate: number
  status: number
  hotUpdate: number
  description: string
}

// 获取版本列表
export const getVersionList = (params?: PaginationParams) => {
  return request.post<ApiResponse<PaginationResponse<Version>>>('/admin/app/version/page', params)
}

// 获取版本详情
export const getVersionInfo = (id: number) => {
  return request.get<ApiResponse<Version>>('/admin/app/version/info', { params: { id } })
}

// 添加版本
export const addVersion = (data: Omit<Version, 'id' | 'tenantId'>) => {
  return request.post<ApiResponse>('/admin/app/version/add', data)
}

// 更新版本
export const updateVersion = (data: Partial<Version>) => {
  return request.post<ApiResponse>('/admin/app/version/update', data)
}

// 删除版本
export const deleteVersion = (id: number) => {
  return request.post<ApiResponse>('/admin/app/version/delete', { id })
}

